package com.itheima.aop;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
@Slf4j
@Aspect
@Component
public class RecordAspect {
    //抽取切入点方法表达式
   /* @Pointcut("execution(* com.itheima.service.Impl.DeptServiceImpl.*(..))")
    public void pointcut(){}

    //前置通知
    @Before("pointcut()")
    public void before(){
        log.info("方法执行前通知");
    }
    @Around("pointcut()")
    public Object record(ProceedingJoinPoint joinPoint) throws Throwable {
        //开始时间
        long start = System.currentTimeMillis();
        //调用执行方法
        Object result = joinPoint.proceed();
        //结束的时间
        long end = System.currentTimeMillis();
        log.info("执行方法耗时：{}", end - start);
        return result;
    }
    //返回通知
    @AfterReturning("pointcut()")
    public void afterReturning(){
        log.info("方法执行后通知");
    }
    //异常通知
    @AfterThrowing("pointcut()")
    public void afterThrowing(){
        log.info("方法执行异常通知");
    }
    //后置通知,运行结束，异常结束，正常结束都通知
    @After("pointcut()")
    public void after(){
        log.info("方法执行完成通知");
    }*/

}
